/****************************************************************/
/*  I M P E T U S     C O P Y R I G H T      S T A T E M E N T  */
/****************************************************************/
/*                                                              */
/*  NOTICE: THIS SOFTWARE CONTAINS TRADE SECRETS THAT BELONG TO */
/*          IMPETUS INFOTECH, AND IS LICENSED BY AN AGREEMENT.  */
/*          ANY UNAUTHORIZED ACCESS, USE, DUPLICATION OR        */
/*          DISCLOSURE IS UNLAWFUL.                             */
/*                                                              */
/*          COPYRIGHT (C) 2008 IMPETUS INFOTECH INDIA PVT LTD   */
/*          ALL RIGHTS RESERVED.                                */
/****************************************************************/


package com.iLabs.spice.handler;

import com.iLabs.pagecode.PageCodeBase;
import com.iLabs.spice.beans.ProfileBean;

/**
 * This class holds rendering information of my friends list.
 * @author iLabs
 * @date 01/08/2008
 */
public class MyFriendsHandler extends PageCodeBase {

	//this attribute handle information for the rendering of the component.
	private boolean renderFriendList;
	//this attribute handle information for the rendering of the component.
	private boolean renderNoFriends;

	/**
	 * This function is used whether the friend list is render or not.
	 * @return boolean
	 */
	public boolean getRenderFriendList() {
		displayFriendList();
		return renderFriendList;
	}
	
	/**
	 * This function is used to determine whether to display friend list or not
	 * Number of friends is retrieved using currentProfile bean
	 * If user has no friends then No Friends label is displayed else
	 * friend list is rendered
	 */

	public void displayFriendList() {

		ProfileBean currentProfile = (ProfileBean) getSessionScope().get(
				"currentProfile");
		
		//Checks whether number of user friends is equal to zero or not
		//If user has no friends then display No Friends label
		//Else Friend List is displayed
		if (currentProfile.getUserFriends().getUserFriendsImages().size() == 0)
		{
			renderFriendList = false;
			renderNoFriends = true;
		}else
		{
			renderFriendList = true;
			renderNoFriends = false;
		}
	}

	/**
	 * This function handle the render information of link for no friends.
	 * @return boolean
	 */
	public boolean getRenderNoFriends() {
		return renderNoFriends;
	}


}
